import { findIndex } from "lodash"
const initState = [];


const collect = (state = initState, action) => {
  switch (action.type) {
    case "addCollection":
      return [
        ...state,
        action.id
      ];
    case "delCollection":
      let currentIndex = findIndex(state, item => item === action.id);
      return [
        ...state.slice(0, currentIndex),
        ...state.slice(currentIndex + 1)
      ];
    default:
      return state;
  }
}

export default collect